package com.smmisia.shop.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Data;
import lombok.Getter;

@Getter
public enum ExchangeEnum {

    NO_NEED_EXCHANGE(0, "无需换票"),
    NEED_EXCHANGE(1, "需要换票");

    @EnumValue
    private Integer code;
    private String desc;

    ExchangeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ExchangeEnum getEnumByCode(Integer code) {
        for (ExchangeEnum exchangeEnum : ExchangeEnum.values()) {
            if (exchangeEnum.getCode().equals(code)) {
                return exchangeEnum;
            }
        }
        return null;
    }
}
